/**
* 构造函数
*/
class ShopProduct2 extends ShopProduct1
{
    
    function __construct($price, $spName, $factory, $cost)
    {
        $this->price = $price;
        $this->spName = $spName;
        $this->factory = $factory;
        $this->cost = $cost;
    }
}

$p3 = new ShopProduct2(99.9, 'php培训服务', 'aliyun', 10);
$p3->setCost(10);
var_dump($p3->spName);
?>
</body>
</html>